﻿using System;
using Lypshare.Flow.Packets;
using Lypshare.Net;

namespace Lypshare.Flow
{
	/// <summary>
	/// Interface flow control.
	/// </summary>
    public interface IFlowControl: IDisposable
    {
        // --------------------------------------------------------
        // Interface Properties
        // --------------------------------------------------------


        /// <summary>
        /// Gets a value indicating whether this instance is empty.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is empty; otherwise, <c>false</c>.
        /// </value>
        bool IsEmpty { get; }


        // --------------------------------------------------------
        // Interface Functions
        // --------------------------------------------------------


        /// <summary>
        /// Send the specified packet.
        /// </summary>
        /// <param name='packet'>
        /// Packet.
        /// </param>
        void Send(Packet packet);


        /// <summary>
        /// Accept the specified packet.
        /// </summary>
        /// <param name='packet'>
        /// If set to <c>true</c> packet.
        /// </param>
        bool Accept(FlowPacket packet);


        /// <summary>
        /// Acknowledge the specified packet.
        /// </summary>
        /// <param name='packet'>
        /// Packet.
        /// </param>
        Packet[] Acknowledge(AckPacket packet);

    } // interface IFlowControl
} // namespace Lypshare.Flow